require(['./config'],() =>{
	require(['template','header','footer','service','jquery'],(template) =>{
		class Index{
			constructor() {
				this.getSearch()
				this.lastIndex = 0
				this.Index = 0
				this.getGong()
				this.getTabs()
				this.getTabspr()
				this.linksTab()
				this.getClick()
			}
			getClick(){
				for(let i =0;i<$(".banner-menu ul li").length;i++){
					$(".banner-menu ul li").eq(i).on('click',() =>{
						this.lastIndex = this.index
						this.index = i 
						$(".banner-menu ul li").children('.banner-itme-img').removeClass('w20')
						$(".banner-menu ul li").eq(this.index).children('.banner-itme-img').addClass('w20')
						$(".banner-menu ul li").parents(".banner-sides").siblings(".banner-frist").children('a').hide()
						$(".banner-menu ul li").parents(".banner-sides").siblings(".banner-frist").children('a').eq(this.index).show()
				})
					
				}
			}
			linksTab(){
				console.log()
				for(let i=0;i<$('.links li').length;i++){
				$('.links li').eq(i).on('click', () =>{
					this.lastIndex = this.index
					this.index = i
					$('.links li').removeClass('sanjiao')
					$('.links li').eq(this.index).addClass('sanjiao')
					$('.links li').eq(this.lastIndex).removeClass('sanjiao')
					$('.links li').parents(".tab2-shop-links").siblings('.tab2-shop-box').children(".tab2-shophover").hide()
					$('.links li').parents(".tab2-shop-links").siblings('.tab2-shop-box').children(".tab2-shophover").eq(this.index).show()
					$('.links li').parents(".tab2-shop-links").siblings('.tab2-shop-box').children(".tab2-shophover").eq(this.lastIndex).hide()
				})
			}
			}
			getGong(){
				let num = 0
				const arr = [ "关于妙趣盒售卖事项的相关说明"," 周边商城用户体验调查"," 周边商城产品销售权说明", "普雷·伊希斯之卵 悬浮灯发货时间公告"]
				const time = ['2019/03/14',"2019/04/01","2019/03/14",'2020/08/20',]
				$('.prev').on('click',() =>{
					num--
					if(num < 0){
						num = arr.length-1
					}
					$('.banner-gong').html(arr[num])
					$('time').html(time[num])
					
				})
				$('.next').on('click',() =>{
					num++
					if(num > arr.length-1){
						num = 0
					}
					$('.banner-gong').html(arr[num])
					$('time').html(time[num])
					
				})
			}
			getTabs(){
				let num = 0
				$('.prevNext .next').on('click',() =>{
					$('.prevNext').eq(num).parents(".tab-goods").addClass('ac')
					num++
					if(num>$('.prevNext .next').length-1){
						num=0
					}
					$('.prevNext .next').eq(num).parents(".tab-goods").removeClass('ac')
				})
				
				
			}
			getTabspr(){
				let num = 0
				$('.prevNext .shang').on('click',() =>{
					$('.prevNext').eq(num).parents(".tab-goods").addClass('ac')
					num--
					$('.prevNext').eq(num).parents(".tab-goods").removeClass('ac')
					if(num<0){
						num = $('.prevNext .shang').length-1
					}
				})
			}
			
			
			getSearch(){
				$.get('http://www.xiongmaoyouxuan.com/api/search?word=%E6%89%8B%E5%8A%9E&start=0&sort=0&couponOnly=0&minPrice=0&maxPrice=99999',resp =>{
					if(resp.code === 200){
						let {list} = resp.data
						let pub = list
						list = list.slice(0,3)
						let list2 = pub.slice(3,7)
						let list3 = pub.slice(7,10)
						let list4 = pub.slice(10,14)
						let list5 = pub.slice(14,15)
						let list6 = pub.slice(15,17)
						let list7 = pub.slice(18,19)
						let list9 = pub.slice(19,27)
						let list10 = pub.slice(27,35)
						$("#tabList").html(template('tabListTemplate',{ list }))
						$("#tabList2").html(template('tabListTemplate2',{ list2 }))
						$("#tabList3").html(template('tabListTemplate3',{ list3 }))
						$("#tabList4").html(template('tabListTemplate4',{ list4 }))
						$("#tabList5").html(template('tabListTemplate5',{ list5 }))
						$("#tabList6").html(template('tabListTemplate6',{ list6 }))
						$("#tabList7").html(template('tabListTemplate7',{ list7 }))
						$("#tabList9").html(template('tabListTemplate9',{ list9 }))
						$("#tabList10").html(template('tabListTemplate10',{ list10 }))
					}
				})
				$.get('http://www.xiongmaoyouxuan.com/api/category/1778/items?start=0&sort=0',resp =>{
					if(resp.code === 200){
						let {list} = resp.data.items
						let arr = list
						let list8 = arr.slice(0,8)
						let list11 = arr.slice(8,16)
						$("#tabList8").html(template('tabListTemplate8',{ list8 }))
						$("#tabList11").html(template('tabListTemplate11',{ list11 }))
						}
				})
				$.get('http://www.xiongmaoyouxuan.com/api/search?word=%E7%94%B7%E8%A1%A3%E6%9C%8D&start=0&sort=0&couponOnly=0&minPrice=0&maxPrice=99999',resp =>{
					if(resp.code === 200){
						let {list} = resp.data
						let arrs = list
						let list12 = arrs.slice(0,8)
						let list13 = arrs.slice(8,13)
						$("#tabList12").html(template('tabListTemplate12',{ list12 }))
						$("#tabList13").html(template('tabListTemplate13',{ list13 }))
						}
				})
				
				
			}
			
		}
		new Index()
	})
})